<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>{{block "title" .}}{{end}}</title>
  <!-- <link href="/assets/css/icons.min.css" rel="stylesheet" type="text/css" /> -->
  <link rel="stylesheet" href="/assets/element/index.css">
  <link rel="stylesheet" href="/assets/css/base.css">
  <script src="/assets/element/vue.js"></script>
  <script src="/assets/element/index.js"></script>
  <script src="/assets/js/axios.min.js"></script>
  <script src="/assets/js/js.cookie.min.js"></script>


  <link href="/assets/css/app.min.css" rel="stylesheet" type="text/css" />
  <link href="/assets/element/index.css" rel="stylesheet">
  <link href="/assets/css/base.css" rel="stylesheet">
  <!-- <script src="/components/base.component.js"></script> -->
  <script src="/assets/libs/jquery/jquery.min.js"></script>
  <script src="/assets/libs/metismenu/metisMenu.min.js"></script>
  <script src="/assets/js/common.js"></script>

  <script type="text/javascript">
    const base_url = '/clothes';
    const base_dir = '';
    const ip = '27.193.4.221';
    const user_info = {
      username: "admin",
      role_id: "1",
    }

    // http response 拦截器
    // axios.interceptors.response.use(
    //   response => {
    //     return response;
    //   },
    //   error => {
    //     console.log(error.response)
    //     alert(error.response)
    //     // if (error.response) {
    //     //   switch (error.response.status) {
    //     //     case 401:
    //     //       // 返回 401 清除 token 信息并跳转到登录页面
    //     //       // store.commit(types.LOGOUT);
    //     //       // router.replace({
    //     //       //   path: 'login',
    //     //       //   query: {
    //     //       //     redirect: router.currentRoute.fullPath
    //     //       //   }
    //     //       // })
    //     //   }
    //     // }
    //     return Promise.reject(error.response.data)
    //     // 返回接口返回的错误信息
    //   });
  </script>
</head>

<body>
  <header id="page-topbar" style="position:fixed;left:0; top:0; z-index:999;">
    <div class="navbar-header">
      <div class="d-flex">
        <div class="navbar-header">
          <div class="d-flex" data-toggle="cospan">
            <i style="margin-left:15px;" id="vertical-menu-btn" class="el-icon-s-fold"></i>
            <i style="margin-left:15px;" @click="reload" class="el-icon-refresh hidden-sm-and-down"></i>
          </div>

          <div class="d-flex hidden-sm-and-down">
            <el-breadcrumb separator="/" style="margin-left:30px;">
              <el-breadcrumb-item v-for="item in levelList" :key="item.path">
                <a v-if="item.title == '首页'" :href="item.path">{{ item.title }}</a>
                <span v-else>{{ item.title }}</span>
              </el-breadcrumb-item>
            </el-breadcrumb>
          </div>
        </div>
      </div>
      <div class="d-flex" style="flex: 1; padding-left: 30px;; text-align: center;font-size:15px;color:red;font-weight:bold;">

      </div>
      <div class="d-flex">
        <div class="iconbutton">
          <el-tooltip content="清除缓存" effect="dark" placement="bottom">
            <i @click="clearCache()" class="icontool el-icon-delete"></i>
          </el-tooltip>
        </div>
        <div class="iconbutton hidden-sm-and-down">
          <el-badge :value="3" is-dot>
            <el-dropdown placement="bottom-start" @click.native="getNotice" trigger="click">
              <i class="icontool el-icon-bell" style="font-size:140%"></i>
              <el-dropdown-menu slot="dropdown">
                <div style="width:250px; height:200px; padding:10px 0; text-indent:10px;">
                  <ul>
                    <li v-for="item in notice">
                      <a :href="item.url">
                        <svg style="width: 1.2em;height: 1.2em;vertical-align: -0.25em;fill: currentColor;overflow: hidden;" id="el-icon-alidaichuli" viewBox="0 0 1024 1024">
                          <path d="M704.2048 935.8848H246.7328c-73.5232 0-133.12-59.5968-133.12-133.12V217.4976c0-73.5232 59.5968-133.12 133.12-133.12h457.472c73.5232 0 133.12 59.5968 133.12 133.12v585.2672c0 73.5232-59.5968 133.12-133.12 133.12z" fill="#FFAC3E"></path>
                          <path d="M639.4368 326.0416H314.368c-22.6304 0-40.96-18.3296-40.96-40.96s18.3296-40.96 40.96-40.96h325.12c22.6304 0 40.96 18.3296 40.96 40.96s-18.3808 40.96-41.0112 40.96zM639.4368 488.448H314.368c-22.6304 0-40.96-18.3296-40.96-40.96s18.3296-40.96 40.96-40.96h325.12c22.6304 0 40.96 18.3296 40.96 40.96s-18.3808 40.96-41.0112 40.96zM470.016 650.8544H314.368c-22.6304 0-40.96-18.3296-40.96-40.96s18.3296-40.96 40.96-40.96h155.648c22.6304 0 40.96 18.3296 40.96 40.96s-18.3296 40.96-40.96 40.96z" fill="#FFFFFF"></path>
                          <path d="M750.2336 743.1168m-189.952 0a189.952 189.952 0 1 0 379.904 0 189.952 189.952 0 1 0-379.904 0Z" fill="#FFAC3E"></path>
                          <path d="M750.2336 552.8064c-104.9088 0-189.952 85.0432-189.952 189.952 0 99.9936 77.2608 181.8624 175.36 189.3376 58.368-14.08 101.7856-66.6624 101.7856-129.3824V573.952a190.21312 190.21312 0 0 0-87.1936-21.1456z" fill="#FF7C0E"></path>
                          <path d="M645.7856 743.1168m-35.9936 0a35.9936 35.9936 0 1 0 71.9872 0 35.9936 35.9936 0 1 0-71.9872 0Z" fill="#FFFFFF"></path>
                          <path d="M750.6432 743.1168m-35.9936 0a35.9936 35.9936 0 1 0 71.9872 0 35.9936 35.9936 0 1 0-71.9872 0Z" fill="#FFFFFF"></path>
                          <path d="M855.5008 743.1168m-35.9936 0a35.9936 35.9936 0 1 0 71.9872 0 35.9936 35.9936 0 1 0-71.9872 0Z" fill="#FFFFFF"></path>
                        </svg>
                        您有<i>{{item.num}}</i> {{item.title}}
                      </a>
                    </li>
                  </ul>
                </div>
              </el-dropdown-menu>
            </el-dropdown>
          </el-badge>
        </div>

        <div class="iconbutton">
          <el-avatar src="/static/img/logo.png" style="vertical-align:middle"></el-avatar>
          <el-dropdown trigger="click" placement="bottom" style="cursor: pointer;margin-right:15px;">
            <span class="el-dropdown-link">
              admin<i style="margin-left:0px; font-size:100%" class="icontool el-icon-arrow-down"></i>
            </span>
            <el-dropdown-menu slot="dropdown">
              <el-dropdown-item icon="el-icon-lock" @click.native.prevent="passwordDialogStatus = true">修改密码</el-dropdown-item>
              <el-dropdown-item icon="el-icon-back" @click.native.prevent="logout">退出</el-dropdown-item>
            </el-dropdown-menu>
          </el-dropdown>
        </div>
        <div class="iconbutton" style="margin-left:0">
          <i class="bx bx-cog bx-spin right-bar-toggle"></i>
        </div>
      </div>
    </div>

    <el-dialog title="重置密码" style="margin-top:100px;" width="450px" :visible="passwordDialogStatus" :before-close="closeForm" append-to-body>
      <el-form :size="size" ref="form" :model="form" :rules="rules" label-width="80px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="新密码" prop="password">
              <el-input show-password autoComplete="off" v-model="form.password" clearable placeholder="请输入密码" />
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="确认密码" prop="repassword">
              <el-input show-password autoComplete="off" v-model="form.repassword" clearable placeholder="请输入确认密码" />
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :size="size" :loading="loading" type="primary" @click="submit">
          <span v-if="!loading">确 定</span>
          <span v-else>提 交 中...</span>
        </el-button>
        <el-button :size="size" @click="closeForm">取 消</el-button>
      </div>
    </el-dialog>
  </header>

  <script>
    new Vue({
      el: '#page-topbar',
      data() {
        var validatePass2 = (rule, value, callback) => {
          if (value === '') {
            callback(new Error('请再次输入密码'))
          } else if (value !== this.form.password) {
            callback(new Error('两次输入密码不一致!'))
          } else {
            callback()
          }
        }
        return {
          form: {
            password: '',
            repassword: '',
          },
          url: {},
          levelList: [],
          notice: [],
          passwordDialogStatus: false,
          loading: false,
          size: 'small',
          urlobj: {}, //这里是判断如果是弹窗链接的话 不显示头部
          rules: {
            password: [{
              required: true,
              message: '密码不能为空',
              trigger: 'blur'
            }],
            repassword: [{
              required: true,
              validator: validatePass2,
              trigger: 'blur'
            }, ],
          }
        }
      },
      mounted() {
        if (sessionStorage.getItem('/adminbreadcrumb')) {
          const menuList = JSON.parse(sessionStorage.getItem('/adminbreadcrumb'))
          this.url = new URL(window.location.href)
          let menus = this.getMenus(menuList)
          let home = [{
            title: '首页',
            path: '/admin/sys/dashboard.html'
          }]
          if (menus !== undefined) {
            if (this.url.pathname !== '/admin/sys/dashboard.html' && this.url.href !== '/admin/sys/dashboard.html') {
              menus = home.concat(menus)
            }
          } else {
            menus = home
          }

          this.levelList = menus
        }
      },
      methods: {
        getMenus(menuList, arr, z) {
          arr = arr || []
          z = z || 0
          for (let i = 0; i < menuList.length; i++) {
            let item = menuList[i]
            arr[z] = item
            if (this.url.pathname === menuList[i].url || this.url.href === menuList[i].url) {
              return arr.slice(0, z + 1)
            }
            if (menuList[i].children && menuList[i].children.length) {
              let res = this.getMenus(menuList[i].children, arr, z + 1)
              if (res) {
                return res
              }
            }
          }
        },
        submit() {
          this.$refs['form'].validate(valid => {
            if (valid) {
              this.loading = true
              this.form['pwd'] = this.form['password']
              axios.post('/admin/adminUser/resetPwd', this.form).then(res => {
                if (res.data.status == 200) {
                  this.$message({
                    message: '操作成功',
                    type: 'success'
                  })
                  this.closeForm()
                } else {
                  this.$message.error('修改失败')
                }
              }).catch(() => {
                this.loading = false
              })
            }
          })
        },
        closeForm() {
          this.passwordDialogStatus = false
          this.loading = false
          if (this.$refs['form'] !== undefined) {
            this.$refs['form'].resetFields()
          }
        },
        getNotice() {
          axios.post('/admin/Index/getNotice').then(res => {
            if (res.data.status == 200) {
              this.notice = res.data.data
            }
          })
        },
        clearCache() {
          this.$confirm('确定清除缓存吗?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            this.$message({
              message: '操作成功',
              type: 'success'
            })
            // axios.post('/admin/Base/clearCache').then(res => {
            //   if (res.data.status == 200) {
            //     this.$message({
            //       message: '操作成功',
            //       type: 'success'
            //     })
            //   }
            // })
          })
        },
        logout() {
          this.$confirm('确定注销并且退出系统?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            type: 'warning'
          }).then(() => {
            axios.get('/logout.html').then(res => {
              if (res.data.status == 200) {
                sessionStorage.setItem('/adminbreadcrumb', '')
                Cookies.set('/adminmenu', '')
                top.parent.frames.location.href = '/'
              }
            })
          })
        },
        reload() {
          location.reload()
        },
      },
    })
  </script>
  <script src="/assets/base.component.js?v=1553"></script>